home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
pcontur2.zip
/
PCONTUR2.BAS
< prev
next >
Wrap
BASIC Source File
|
1993-07-23
|
4KB
|
185 lines
'*****************REM READ DATA FILE
PRINT "SAMPLE DATA IS ' TEST.CSV ' "
INPUT "ENTER FILE NAME "; F$
'F$ = "TEST.CSV"
INF = FREEFILE
OPEN F$ FOR INPUT AS #INF
TSR% = 1
INPUT #1, NR
INPUT #1, NC
INPUT #1, MAX
INPUT #1, MIN
INPUT #1, DX
INPUT #1, DY
DIM H((NR - 1), (NC - 1))
FOR I = (NR - 1) TO 0 STEP -1
FOR J = 0 TO (NC - 1)
INPUT #1, H1
H(I, J) = H1
NEXT J
NEXT I
CLOSE #INF
SCR% = 1 'COLOR
SCD% = 2 'COLOR
60 ON (SCR% + 1) GOTO 62, 64, 66
62 SCREEN 0: WIDTH 40: GOTO 80
64 SCREEN 1: GOTO 68
66 SCREEN 1: GOTO 80
68 IF SCD% = 1 THEN 80
70 COLOR 8, 0
80 KEY OFF
90 SR% = 1: RGB% = 0
2000 CLS
2002 SCREEN SCR%: IF SCR% = 0 THEN 2010
2004 IF SCR% = 1 THEN 2008
2006 SCREEN 1: GOTO 2010
2008 COLOR 8, 0
2010
'2040 PRINT "ROWS = "; NR
'PRINT "COLUMNS = "; NC
'PRINT "MIN = "; MIN; " MAX = "; MAX
'PRINT "SR% = "; SR%
'INPUT DUM$
'************************** CONTOUR
3000 CLS : SCREEN SR%
SCREEN 12
GX = 5 * SR%: GY = 5: MG = 0: MH = 0: MV = 0: SX = 240 * SR%: SY = 180: PP = 0
MH = SX / ((NC - 1) * SR%): MV = SY / (NR - 1)
IF MH <= MV THEN MG = MH ELSE MG = MV
WINDOW (0, 0)-(320 * SR%, 200)
IF SR% = 1 THEN RGB = 2 ELSE RGB = 3
PX = GX + (MG * (NC - 1) * SR%): PY = GY + MG * (NR - 1)
3070 LINE (GX, GY)-(PX, PY), RGB, B
IF SR% = 1 THEN 3100
3090 LINE (GX - 1, GY)-(PX - 1, PY), RGB, B
3100 FOR I = 10 TO (NC - 10) STEP 10
FOR J = 10 TO (NR - 10) STEP 10
GPX0 = GX + (MG * I * SR%)
GPX1 = GPX0 - 5 * SR%: GPX2 = GPX0 + 5 * SR%
GPY0 = GY + (MG * J)
GPY1 = GPY0 - 5: GPY2 = GPY0 + 5
LINE (GPX1, GPY0)-(GPX2, GPY0), RGB
LINE (GPX0, GPY1)-(GPX0, GPY2), RGB
NEXT J
NEXT I
3195 IF PP = 1 THEN 3880
3200 REM START OF "MORE CONTOURS "
'LOCATE 1, 2: PRINT "MIN "; MIN; " MAX "; MAX
'LOCATE 3, 32 * TSR%: PRINT "CONTOURS"
'LOCATE 5, 32 * TSR%: INPUT "LOW "; LC
'LOCATE 6, 32 * TSR%: INPUT "HIGH "; HC
'LOCATE 10, 32 * TSR%: INPUT "CI "; CI
LC = MIN
HC = MAX
CI = 2
3280 IF LC < (MIN - CI) THEN LC = LC + CI
IF HC > MAX THEN HC = MAX
3300 FOR CC = LC TO HC STEP CI
'LOCATE 12, 32 * TSR%: PRINT CC
3320 FOR I = 0 TO (NR - 2)
3330 Y0 = MG * I
FOR J = 0 TO (NC - 2) 'LINE 3340
X0 = MG * J
NP = 0
Z1 = H(I, J)
IF CC > Z1 THEN NP = NP + 1
Z2 = H(I, (J + 1))
IF CC > Z2 THEN NP = NP + 1
Z3 = H((I + 1), J)
IF CC > Z3 THEN NP = NP + 1
Z4 = H((I + 1), (J + 1))
IF CC > Z4 THEN NP = NP + 1
IF NP = 0 OR NP = 4 THEN GOTO 3840
A = Z1
B = Z2 - A
C = Z3 - A
D = Z4 - A - B - C
ZT = 0
FOR Y1 = 0 TO 1 STEP .25
DR = B + D * Y1
IF DR = 0 GOTO 3680
X1 = (CC - A - C * Y1) / DR
IF X1 < 0 OR X1 > 1 GOTO 3680
X = X0 + MG * X1
Y = Y0 + MG * Y1
3580 IF X > PX OR Y > PY GOTO 3670
IF ZT = 0 THEN 3620
3600 LINE -((X * SR% + GX), (Y + GY)), 1
GOTO 3670
3620 PSET ((X * SR% + GX), (Y + GY)), 1
IF TL > 0 THEN 3670
IF CC / 10 <> INT(CC / 10) THEN 3670
CCOL = (X * SR% + GX) / 8: CROW = (Y + GY) / 8
IF CCOL < 2 * SR% THEN CCOL = 2 * SR%
IF CCOL > 27 * SR% THEN CCOL = 27 * SR%
IF CROW <= 2 THEN CROW = 2
IF CROW > 22 THEN CROW = 22
IF CC / 20 <> INT(CC / 20) THEN 3639
3638 LOCATE (25 - CROW), CCOL: GOTO 3640
3639 LOCATE (24 - CROW), CCOL
3640
'3640 PRINT CC
3650 TL = TL + 1
3660 GOTO 3620
3670 ZT = ZT + 1
3680 NEXT Y1
ZT = 0
FOR X1 = 0 TO 1 STEP .25
DS = C + D * X1
IF DS = 0 GOTO 3830
Y1 = (CC - A - B * X1) / DS
IF Y1 < 0 OR Y1 > 1 GOTO 3830
3750 X = X0 + MG * X1
Y = Y0 + MG * Y1
3770 IF X > PX OR Y > PY GOTO 3820
3780 IF ZT = 0 THEN 3810
3790 LINE -((X * SR% + GX), (Y + GY)), 1
3800 GOTO 3820
3810 PSET ((X * SR% + GX), (Y + GY)), 1
3820 ZT = ZT + 1
3830 NEXT X1
3840 NEXT J
3850 NEXT I
TL = 0
3870 NEXT CC
3875 PP = 1: GOTO 3070
'3880 GOTO 3200 'NEW
'3880 LOCATE 14, 32 * TSR%: PRINT "SCREEN"
3880 LOCATE 5, 50 * TSR%: INPUT "(M)ore or (E)nd "; M$
IF M$ = UCASE$("M") THEN
GOTO 3200
ELSE
END
END IF